\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph}{}\section{Introduction\+To\+Algorithm\+:\+:Graph\+Algorithm\+:\+:Matrix\+Graph$<$ N $>$ Struct Template Reference}
\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph$<$ N $>$@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph$<$ N $>$}}


Matrix\+Graph：图的矩阵表示，算法导论22章22.1节  




{\ttfamily \#include $<$matrixgraph.\+h$>$}

\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
typedef int \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}{V\+I\+D\+Type}
\item 
typedef int \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_af54dbf6d171b89b81b490de13f1fb02f}{E\+Weight\+Type}
\item 
typedef std\+::tuple$<$ \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}{V\+I\+D\+Type}, \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}{V\+I\+D\+Type}, \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_af54dbf6d171b89b81b490de13f1fb02f}{E\+Weight\+Type} $>$ \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ad698e07bacdb3f332c4f5d34bdb49463}{Edge\+Tuple\+Type}
\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_abe357f589d4b46be1cbb8b36d7434681}{Matrix\+Graph} (\hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_af54dbf6d171b89b81b490de13f1fb02f}{E\+Weight\+Type} val)
\begin{DoxyCompactList}\small\item\em 显式构造函数，指定{\ttfamily invalid\+\_\+weight} \end{DoxyCompactList}\item 
\hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a5e0154a5eed096fe10a03519022fd24d}{Matrix\+Graph} ()
\begin{DoxyCompactList}\small\item\em 默认构造函数，指定{\ttfamily invalid\+\_\+weight}为0 \end{DoxyCompactList}\item 
void \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a91283bb66d4daa938cd521d348e00984}{add\+\_\+edge} (const \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ad698e07bacdb3f332c4f5d34bdb49463}{Edge\+Tuple\+Type} \&edge\+\_\+tuple)
\begin{DoxyCompactList}\small\item\em add\+\_\+edge\+:添加一条边 \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Iteator $>$ }\\void \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a0fac196d4c47c2855267eb2cf888ef14}{add\+\_\+edges} (const Iteator \&begin, const Iteator \&end)
\begin{DoxyCompactList}\small\item\em add\+\_\+edges\+:添加一组边 \end{DoxyCompactList}\item 
void \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_aa16d1f2e6949d0adccc30b0704013e6d}{adjust\+\_\+edge} (\hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}{V\+I\+D\+Type} id1, \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}{V\+I\+D\+Type} id2, \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_af54dbf6d171b89b81b490de13f1fb02f}{E\+Weight\+Type} wt)
\begin{DoxyCompactList}\small\item\em adjust\+\_\+edge\+:修改一条边的权重 \end{DoxyCompactList}\item 
const std\+::vector$<$ \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ad698e07bacdb3f332c4f5d34bdb49463}{Edge\+Tuple\+Type} $>$ \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a2bad3638c9ecb614f65b19fe155f5cd7}{edge\+\_\+tuples} () const 
\begin{DoxyCompactList}\small\item\em edge\+\_\+tuples\+:返回图中所有边的三元素元组集合，这里集合采用{\ttfamily std\+::vector$<$std\+::tuple$<$V\+I\+D\+Type,V\+I\+D\+Type,E\+Weight\+Type$>$$>$} \end{DoxyCompactList}\item 
const std\+::vector$<$ \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ad698e07bacdb3f332c4f5d34bdb49463}{Edge\+Tuple\+Type} $>$ \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a906d21b803bfae5095066df1e31c891c}{vertex\+\_\+edge\+\_\+tuples} (\hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}{V\+I\+D\+Type} id) const 
\begin{DoxyCompactList}\small\item\em vertex\+\_\+edge\+\_\+tuples\+:返回图中从指定顶点出发的边的三元素元组集合，这里集合采用{\ttfamily std\+::vector$<$std\+::tuple$<$V\+I\+D\+Type,V\+I\+D\+Type,E\+Weight\+Type$>$$>$} \end{DoxyCompactList}\item 
bool \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ab5eb0a563c39a088d16e349cb3d73a2d}{has\+\_\+edge} (\hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}{V\+I\+D\+Type} id\+\_\+from, \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}{V\+I\+D\+Type} id\+\_\+to) const 
\begin{DoxyCompactList}\small\item\em has\+\_\+edge\+:返回图中指定顶点之间是否存在边 \end{DoxyCompactList}\item 
\hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_af54dbf6d171b89b81b490de13f1fb02f}{E\+Weight\+Type} \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a9304b6a4c45f368452f6ff9065334536}{weight} (\hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}{V\+I\+D\+Type} id\+\_\+from, \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}{V\+I\+D\+Type} id\+\_\+to) const 
\begin{DoxyCompactList}\small\item\em weight\+:返回图中指定顶点之间的边的权重 \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item 
std\+::array$<$ std\+::array$<$ \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_af54dbf6d171b89b81b490de13f1fb02f}{E\+Weight\+Type}, N $>$, N $>$ \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae1febbc0e4a86c325a16a942947a03bf}{matrix}
\item 
const \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_af54dbf6d171b89b81b490de13f1fb02f}{E\+Weight\+Type} \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_accc79376e509d7ffa016ef5003512976}{invalid\+\_\+weight}
\end{DoxyCompactItemize}
\subsection*{Static Public Attributes}
\begin{DoxyCompactItemize}
\item 
static const unsigned \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a68d153cb2714464d5c432d667e29f28f}{N\+U\+M} =N
\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$unsigned N$>$struct Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph$<$ N $>$}

Matrix\+Graph：图的矩阵表示，算法导论22章22.1节 

图的矩阵主要包含两个数据：


\begin{DoxyItemize}
\item {\ttfamily matrix}：一个矩阵，类型为{\ttfamily std\+::array$<$std\+::array$<$E\+Weight\+Type,N$>$, N$>$}，为{\ttfamily N$\ast$\+N}大小：
\item {\ttfamily invalid\+\_\+weight}：无效权重。当矩阵中{\ttfamily r}行{\ttfamily c}列数据为该值时，表示编号为{\ttfamily r}与{\ttfamily c}的顶点之间没有连接
\end{DoxyItemize}

为了便于计算，这里并不管理边和顶点，只是维护矩阵。边、顶点与矩阵的同步由使用者确保。 

Definition at line 37 of file matrixgraph.\+h.



\subsection{Member Typedef Documentation}
\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ad698e07bacdb3f332c4f5d34bdb49463}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!Edge\+Tuple\+Type@{Edge\+Tuple\+Type}}
\index{Edge\+Tuple\+Type@{Edge\+Tuple\+Type}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{Edge\+Tuple\+Type}]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ typedef std\+::tuple$<${\bf V\+I\+D\+Type},{\bf V\+I\+D\+Type},{\bf E\+Weight\+Type}$>$ {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::{\bf Edge\+Tuple\+Type}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ad698e07bacdb3f332c4f5d34bdb49463}
边的三元素（顶点1编号，顶点2编号，权重)组成的元组 

Definition at line 41 of file matrixgraph.\+h.

\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_af54dbf6d171b89b81b490de13f1fb02f}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!E\+Weight\+Type@{E\+Weight\+Type}}
\index{E\+Weight\+Type@{E\+Weight\+Type}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{E\+Weight\+Type}]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ typedef int {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::{\bf E\+Weight\+Type}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_af54dbf6d171b89b81b490de13f1fb02f}
权重的类型 

Definition at line 40 of file matrixgraph.\+h.

\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!V\+I\+D\+Type@{V\+I\+D\+Type}}
\index{V\+I\+D\+Type@{V\+I\+D\+Type}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{V\+I\+D\+Type}]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ typedef int {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::{\bf V\+I\+D\+Type}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae97378c88e8d65a880334f31a352e71d}
顶点编号的类型 

Definition at line 39 of file matrixgraph.\+h.



\subsection{Constructor \& Destructor Documentation}
\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_abe357f589d4b46be1cbb8b36d7434681}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!Matrix\+Graph@{Matrix\+Graph}}
\index{Matrix\+Graph@{Matrix\+Graph}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{Matrix\+Graph(\+E\+Weight\+Type val)}]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::{\bf Matrix\+Graph} (
\begin{DoxyParamCaption}
\item[{{\bf E\+Weight\+Type}}]{val}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [explicit]}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_abe357f589d4b46be1cbb8b36d7434681}


显式构造函数，指定{\ttfamily invalid\+\_\+weight} 


\begin{DoxyParams}{Parameters}
{\em val\+:无效权重值} & \\
\hline
\end{DoxyParams}


Definition at line 47 of file matrixgraph.\+h.

\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a5e0154a5eed096fe10a03519022fd24d}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!Matrix\+Graph@{Matrix\+Graph}}
\index{Matrix\+Graph@{Matrix\+Graph}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{Matrix\+Graph()}]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::{\bf Matrix\+Graph} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a5e0154a5eed096fe10a03519022fd24d}


默认构造函数，指定{\ttfamily invalid\+\_\+weight}为0 



Definition at line 54 of file matrixgraph.\+h.



\subsection{Member Function Documentation}
\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a91283bb66d4daa938cd521d348e00984}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!add\+\_\+edge@{add\+\_\+edge}}
\index{add\+\_\+edge@{add\+\_\+edge}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{add\+\_\+edge(const Edge\+Tuple\+Type \&edge\+\_\+tuple)}]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ void {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::add\+\_\+edge (
\begin{DoxyParamCaption}
\item[{const {\bf Edge\+Tuple\+Type} \&}]{edge\+\_\+tuple}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a91283bb66d4daa938cd521d348e00984}


add\+\_\+edge\+:添加一条边 


\begin{DoxyParams}{Parameters}
{\em edge\+\_\+tuple\+:一条边的三元素元组} & 为了便于计算，添加边时并不是添加{\ttfamily \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_edge}{Edge}}类型，而是{\ttfamily std\+::tuple$<$V\+I\+D\+Type,V\+I\+D\+Type,E\+Weight\+Type$>$}类型的值。\\
\hline
\end{DoxyParams}
如果指定节点之间的边已经存在，则抛出{\ttfamily std\+::invalid\+\_\+argument}异常 \begin{quote}
要求边的顶点均在{\ttfamily \mbox{[}0,N)}这个半闭半开区间。如果任何一个值超过该区间则认为顶点{\ttfamily id}无效，直接返回而不作添加\end{quote}


Definition at line 66 of file matrixgraph.\+h.

\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a0fac196d4c47c2855267eb2cf888ef14}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!add\+\_\+edges@{add\+\_\+edges}}
\index{add\+\_\+edges@{add\+\_\+edges}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{add\+\_\+edges(const Iteator \&begin, const Iteator \&end)}]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ template$<$typename Iteator $>$ void {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::add\+\_\+edges (
\begin{DoxyParamCaption}
\item[{const Iteator \&}]{begin, }
\item[{const Iteator \&}]{end}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a0fac196d4c47c2855267eb2cf888ef14}


add\+\_\+edges\+:添加一组边 


\begin{DoxyParams}{Parameters}
{\em begin\+:边容器的起始迭代器} & \\
\hline
{\em end\+:边容器的终止迭代器} & 为了便于计算，添加边时并不是添加{\ttfamily \hyperlink{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_edge}{Edge}}类型，而是{\ttfamily std\+::tuple$<$V\+I\+D\+Type,V\+I\+D\+Type,E\+Weight\+Type$>$}类型的值\\
\hline
\end{DoxyParams}
如果指定节点之间的边已经存在，则抛出{\ttfamily std\+::invalid\+\_\+argument}异常 \begin{quote}
要求边的顶点均在{\ttfamily \mbox{[}0,N)}这个半闭半开区间。如果任何一个值超过该区间则认为顶点{\ttfamily id}无效，直接返回而不作添加\end{quote}


Definition at line 87 of file matrixgraph.\+h.

\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_aa16d1f2e6949d0adccc30b0704013e6d}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!adjust\+\_\+edge@{adjust\+\_\+edge}}
\index{adjust\+\_\+edge@{adjust\+\_\+edge}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{adjust\+\_\+edge(\+V\+I\+D\+Type id1, V\+I\+D\+Type id2, E\+Weight\+Type wt)}]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ void {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::adjust\+\_\+edge (
\begin{DoxyParamCaption}
\item[{{\bf V\+I\+D\+Type}}]{id1, }
\item[{{\bf V\+I\+D\+Type}}]{id2, }
\item[{{\bf E\+Weight\+Type}}]{wt}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_aa16d1f2e6949d0adccc30b0704013e6d}


adjust\+\_\+edge\+:修改一条边的权重 


\begin{DoxyParams}{Parameters}
{\em id1\+:待修改边的第一个顶点} & \\
\hline
{\em id2\+:待修改边的第二个顶点} & \\
\hline
{\em wt\+:新的权重} & 修改顶点{\ttfamily id1}和{\ttfamily id2}直接的边的权重为{\ttfamily wt}。如果指定结点之间的边不存在，则抛出{\ttfamily std\+::invalid\+\_\+argument}异常。 \begin{quote}
要求{\ttfamily id1}和{\ttfamily id2}均在{\ttfamily \mbox{[}0,N)}这个半闭半开区间。如果任何一个值超过该区间则认为顶点{\ttfamily id}无效，直接返回而不作权重修改\end{quote}
\\
\hline
\end{DoxyParams}


Definition at line 108 of file matrixgraph.\+h.

\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a2bad3638c9ecb614f65b19fe155f5cd7}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!edge\+\_\+tuples@{edge\+\_\+tuples}}
\index{edge\+\_\+tuples@{edge\+\_\+tuples}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{edge\+\_\+tuples() const }]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ const std\+::vector$<${\bf Edge\+Tuple\+Type}$>$ {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::edge\+\_\+tuples (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a2bad3638c9ecb614f65b19fe155f5cd7}


edge\+\_\+tuples\+:返回图中所有边的三元素元组集合，这里集合采用{\ttfamily std\+::vector$<$std\+::tuple$<$V\+I\+D\+Type,V\+I\+D\+Type,E\+Weight\+Type$>$$>$} 

\begin{DoxyReturn}{Returns}
\+:图中所有边的三元素元组集合 
\end{DoxyReturn}


Definition at line 121 of file matrixgraph.\+h.

\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ab5eb0a563c39a088d16e349cb3d73a2d}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!has\+\_\+edge@{has\+\_\+edge}}
\index{has\+\_\+edge@{has\+\_\+edge}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{has\+\_\+edge(\+V\+I\+D\+Type id\+\_\+from, V\+I\+D\+Type id\+\_\+to) const }]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ bool {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::has\+\_\+edge (
\begin{DoxyParamCaption}
\item[{{\bf V\+I\+D\+Type}}]{id\+\_\+from, }
\item[{{\bf V\+I\+D\+Type}}]{id\+\_\+to}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ab5eb0a563c39a088d16e349cb3d73a2d}


has\+\_\+edge\+:返回图中指定顶点之间是否存在边 


\begin{DoxyParams}{Parameters}
{\em id\+\_\+from} & 第一个顶点的{\ttfamily id} \\
\hline
{\em id\+\_\+to} & 第二个顶点的{\ttfamily id} \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\+:第一个顶点和第二个顶点之间是否存在边
\end{DoxyReturn}

\begin{DoxyItemize}
\item 当{\ttfamily id\+\_\+from}与{\ttfamily id\+\_\+to}无效时，抛出异常 $>$这里的无效值得是{\ttfamily id\+\_\+from}、{\ttfamily id\+\_\+to}不在区间{\ttfamily \mbox{[}0,N)}之间
\item 当{\ttfamily id\+\_\+from}与{\ttfamily id\+\_\+to}之间有边时，返回{\ttfamily true}
\item 当{\ttfamily id\+\_\+from}与{\ttfamily id\+\_\+to}之间没有边时，返回{\ttfamily false} 
\end{DoxyItemize}

Definition at line 168 of file matrixgraph.\+h.

\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a906d21b803bfae5095066df1e31c891c}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!vertex\+\_\+edge\+\_\+tuples@{vertex\+\_\+edge\+\_\+tuples}}
\index{vertex\+\_\+edge\+\_\+tuples@{vertex\+\_\+edge\+\_\+tuples}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{vertex\+\_\+edge\+\_\+tuples(\+V\+I\+D\+Type id) const }]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ const std\+::vector$<${\bf Edge\+Tuple\+Type}$>$ {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::vertex\+\_\+edge\+\_\+tuples (
\begin{DoxyParamCaption}
\item[{{\bf V\+I\+D\+Type}}]{id}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a906d21b803bfae5095066df1e31c891c}


vertex\+\_\+edge\+\_\+tuples\+:返回图中从指定顶点出发的边的三元素元组集合，这里集合采用{\ttfamily std\+::vector$<$std\+::tuple$<$V\+I\+D\+Type,V\+I\+D\+Type,E\+Weight\+Type$>$$>$} 


\begin{DoxyParams}{Parameters}
{\em id} & 指定顶点{\ttfamily id} \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\+:图中指定顶点出发的边的三元素元组集合
\end{DoxyReturn}

\begin{DoxyItemize}
\item 如果指定的顶点{\ttfamily id}不在{\ttfamily \mbox{[}0,N)}之间，则无效 
\end{DoxyItemize}

Definition at line 141 of file matrixgraph.\+h.

\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a9304b6a4c45f368452f6ff9065334536}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!weight@{weight}}
\index{weight@{weight}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{weight(\+V\+I\+D\+Type id\+\_\+from, V\+I\+D\+Type id\+\_\+to) const }]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ {\bf E\+Weight\+Type} {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::weight (
\begin{DoxyParamCaption}
\item[{{\bf V\+I\+D\+Type}}]{id\+\_\+from, }
\item[{{\bf V\+I\+D\+Type}}]{id\+\_\+to}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a9304b6a4c45f368452f6ff9065334536}


weight\+:返回图中指定顶点之间的边的权重 


\begin{DoxyParams}{Parameters}
{\em id\+\_\+from} & 第一个顶点的{\ttfamily id} \\
\hline
{\em id\+\_\+to} & 第二个顶点的{\ttfamily id} \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\+:第一个顶点和第二个顶点之间的边的权重
\end{DoxyReturn}
当且仅当{\ttfamily id\+\_\+from}与{\ttfamily id\+\_\+to}之间存在边时返回该边的权重。其他情况下都会抛出{\ttfamily std\+::invalid\+\_\+argument}异常


\begin{DoxyItemize}
\item 当{\ttfamily id\+\_\+from}与{\ttfamily id\+\_\+to}无效时，抛出异常 $>$这里的无效值得是{\ttfamily id\+\_\+from}、{\ttfamily id\+\_\+to}不在区间{\ttfamily \mbox{[}0,N)}之间
\item 当{\ttfamily id\+\_\+from}与{\ttfamily id\+\_\+to}之间无边时，抛出异常 
\end{DoxyItemize}

Definition at line 189 of file matrixgraph.\+h.



\subsection{Member Data Documentation}
\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_accc79376e509d7ffa016ef5003512976}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!invalid\+\_\+weight@{invalid\+\_\+weight}}
\index{invalid\+\_\+weight@{invalid\+\_\+weight}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{invalid\+\_\+weight}]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ const {\bf E\+Weight\+Type} {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::invalid\+\_\+weight}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_accc79376e509d7ffa016ef5003512976}
无效权重，是一个const值，一旦图被初始化之后就无法改变 

Definition at line 201 of file matrixgraph.\+h.

\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae1febbc0e4a86c325a16a942947a03bf}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!matrix@{matrix}}
\index{matrix@{matrix}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{matrix}]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ std\+::array$<$std\+::array$<${\bf E\+Weight\+Type},N$>$, N$>$ {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::matrix}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_ae1febbc0e4a86c325a16a942947a03bf}
图的矩阵 

Definition at line 200 of file matrixgraph.\+h.

\hypertarget{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a68d153cb2714464d5c432d667e29f28f}{}\index{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}!N\+U\+M@{N\+U\+M}}
\index{N\+U\+M@{N\+U\+M}!Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph@{Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}}
\subsubsection[{N\+U\+M}]{\setlength{\rightskip}{0pt plus 5cm}template$<$unsigned N$>$ const unsigned {\bf Introduction\+To\+Algorithm\+::\+Graph\+Algorithm\+::\+Matrix\+Graph}$<$ N $>$\+::N\+U\+M =N\hspace{0.3cm}{\ttfamily [static]}}\label{struct_introduction_to_algorithm_1_1_graph_algorithm_1_1_matrix_graph_a68d153cb2714464d5c432d667e29f28f}
顶点的最大容量 

Definition at line 42 of file matrixgraph.\+h.



The documentation for this struct was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
src/graph\+\_\+algorithms/basic\+\_\+graph/graph\+\_\+representation/matrix\+\_\+graph/\hyperlink{matrixgraph_8h}{matrixgraph.\+h}\end{DoxyCompactItemize}
